package net.dengzixu.java.homework.period39.homework1;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * @author Deng Zixu <admin@dengzixu.com>
 */
public class Homework {
    public static void main(String[] args) {
        Map<String, String> courseList = new HashMap<>(8);

        // 将基础信息放入 Map
        courseList.put("张明", "Java");
        courseList.put("赵颖", "JSP");
        courseList.put("刘恒", "JSP");
        courseList.put("王维", "Oracle");

        // 增加一位老师 "关鑫" 教 JDBC
        courseList.put("关鑫", "JDBC");

        // "王维" 改为教 JSP
        courseList.put("王维", "JSP");

        // 把 Map 的 key 放入 Set 中 并遍历
        Set<String> teacherNameSet = courseList.keySet();

        for (String teacherName : teacherNameSet) {
            System.out.printf("教师: %s, 课程: %s\n", teacherName, courseList.get(teacherName));
        }

        for (Map.Entry<String, String> entry : courseList.entrySet()) {
            if ("JSP".equals(entry.getValue())) {
                System.out.printf("%s 教师教JSP\n", entry.getKey());
            }
        }
    }
}
